//
//  GRXChatTVC.m
//  1-MushroomStreet-自定义tabbar
//
//  Created by xmg on 15/12/8.
//  Copyright © 2015年 grx. All rights reserved.
//

#import "GRXChatTVC.h"

#import "GRXCustomMenu.h"

#import "GRXMassesManageController.h"

#import "GRXCreatMassessManageController.h"

@interface GRXChatTVC ()<GRXCustomMenuDelegate>

/**弹框菜单*/
@property (nonatomic, strong) GRXCustomMenu *menu;

@end

@implementation GRXChatTVC

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = @"聊聊聊";
    
    
    if (self.isLogin == NO) {
        return;
    }
    
    self.view.backgroundColor = [UIColor greenColor];
    
    [self setUpNavigation];
    
    
    
}

- (void)setUpNavigation{

    UIBarButtonItem *rightItem = [UIBarButtonItem itemWithNorImage:[UIImage imageNamed:@"dd_contacts_right_bar"] highImage:[UIImage imageNamed:@"dd_contacts_right_bar"] target:self action:@selector(addFriendClick)];
    
    self.navigationItem.rightBarButtonItem = rightItem;
}

- (void)addFriendClick{
    NSLog(@"点击了添加好友");
    
    //    NSLog(@"点击了添加按钮");
    
    __weak __typeof(self) weakSelf = self;
    if (!self.menu) {
        
        self.menu = [[GRXCustomMenu alloc] initWithDataArr:@[@"群管理", @"创建群聊"] origin:CGPointMake(0, GRXNavgationBarMaxY) width:120 rowHeight:44];

        _menu.delegate = self;
        _menu.dismiss = ^() {
            weakSelf.menu = nil;
        };
        _menu.arrImgName = @[@"schoolListItem",@"schoolListItem"];
        [self.view addSubview:_menu];
    } else {
        [_menu dismissWithCompletion:^(GRXCustomMenu *object) {
            weakSelf.menu = nil;
        }];
    }
}


//弹窗效果
- (void)customMenu:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"select: %ld", indexPath.row);
    
    switch (indexPath.row) {
        case 0:
            {
                GRXMassesManageController *massesVC = [[GRXMassesManageController alloc] init];
                
                // 隐藏底部条:条件:在跳转之前设置
                massesVC.hidesBottomBarWhenPushed = YES;
                
                [self.navigationController pushViewController:massesVC animated:YES];
                
            }
            break;
            
        case 1:
        {
            GRXCreatMassessManageController *creatVC = [[GRXCreatMassessManageController alloc] init];
            
            // 隐藏底部条:条件:在跳转之前设置
            creatVC.hidesBottomBarWhenPushed = YES;
            
            [self.navigationController pushViewController:creatVC animated:YES];
            
        }
            break;
            
        default:
            break;
    }
    
    
    
}


- (void)viewDidDisappear:(BOOL)animated{
    __weak __typeof(self) weakSelf = self;
    [super viewDidDisappear:animated];
    
    [_menu dismissWithCompletion:^(GRXCustomMenu *object) {
        weakSelf.menu = nil;
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
